//
//  MainViewController.swift
//  JIMWeiBo
//
//  Created by 陈恒均 on 2018/2/7.
//  Copyright © 2018年 陈恒均. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    
    // MARK:- 懒加载属性
    private lazy var composeBtn :UIButton = UIButton(imageName: "tabbar_compose_icon_add", bgImageName: "tabbar_compose_button")
    
    
    // MARK:- 系统回调函数
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func viewWillLayoutSubviews() {
        setupComposeBtn()
    }
}

// MARK:- 设置UI界面
extension MainViewController
{
    func setupComposeBtn() {
        tabBar.addSubview(composeBtn)
   
        composeBtn.center = CGPoint(x: tabBar.center.x, y: tabBar.bounds.size.height * 0.5)
        composeBtn.addTarget(self, action: #selector(MainViewController.composeBtnClick), for: .touchUpInside)
    }
}

// MARK:- 事件监听
extension MainViewController
{
    
    @objc private func composeBtnClick()
    {
        let composeVc = ComposeViewController()
        let comNav = UINavigationController(rootViewController: composeVc)
        
        present(comNav, animated: true, completion: nil)
        
        
    }
}
